cmake_minimum_required(VERSION 3.16)

project(TetrisGame VERSION 1.0.0 LANGUAGES CXX)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 自动处理UI、资源和MOC文件
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

# 查找所需的Qt包
find_package(Qt6 REQUIRED COMPONENTS Core Widgets)

# 设置可执行文件
add_executable(TetrisGame
    main.cpp
)

# 链接Qt库
target_link_libraries(TetrisGame Qt6::Core Qt6::Widgets)

# 设置目标属性
target_compile_definitions(TetrisGame PRIVATE "$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>")

# 在Windows上设置子系统（避免显示控制台窗口）
if(WIN32)
    set_target_properties(TetrisGame PROPERTIES
        WIN32_EXECUTABLE ON
    )
endif()

# 安装目标
install(TARGETS TetrisGame
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# 包含当前目录
target_include_directories(TetrisGame PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# 发布配置的可选设置
if(CMAKE_BUILD_TYPE STREQUAL "Release")
    target_compile_definitions(TetrisGame PRIVATE QT_NO_DEBUG_OUTPUT)
endif()